home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 January - Disc 2 / Macworld (1999-01) (Disk 2).dmg / Serious Demos / Symbolic Composer 4.2 / Environment / Projects / Questions & Answers / Q&A Programming Music / How to process ratios? < prev    next >
Lisp/Scheme  |  1998-10-26  |  1KB  |  39 lines

  1. HOW TO PROCESS RATIOS
  2.  
  3. If you want to process ratios you must use get-ratio,
  4.  
  5. (+ (get-ratio '3/1 :ratio) (get-ratio '3/4 :ratio))
  6.  
  7. Rational processing is changed in favour of length unit processing that
  8. handles dots and -n divisions.
  9.  
  10. You can restore Lisp ratio processing with remove-new-ratio-parser.
  11.  
  12. SCOM Lengths vs. Lisp Ratios
  13.  
  14. You can switch between SCOM Lengths and Lisp ratio parsing with
  15. two functions (remove-new-ratio-parser) and (install-new-ratio-parser).
  16.  
  17. (install-new-ratio-parser) is the default behaviour. It allows to
  18. use length symbols that are greater than 1/1 and result to integers
  19. without backslashing.
  20.  
  21. (setq zones '(1/1 1/2 1/3 1/4 ...))
  22.  
  23. (remove-new-ratio-parser) changes the ratio parsing back to standard
  24. Lisp. In this mode you can calculate with ratios:
  25.  
  26. (+ 1/3 2/3)
  27. 1
  28.  
  29. You cannot naturally calculate with length symbols:
  30.  
  31. (+ 1/3. 1/4..)
  32.  
  33. In this mode you have to backslash all length symbols like 1/1, 2/1, 3/1.
  34.  
  35. (setq zones '(1\/1 2\/1 3\/1))
  36.  
  37. This looks confusing for the first time user, hence it the new-ratio-parser 
  38. is default.
  39.